package com.baizhi.cmfz.service.impl;

import com.baizhi.cmfz.dao.ArticleDao;
import com.baizhi.cmfz.entity.Article;
import com.baizhi.cmfz.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class ArticleServiceImpl implements ArticleService {
    @Autowired(required = false)
    private ArticleDao articleDao;
    Map map = new HashMap();
    @Override
    @Transactional
    public Map selectArticle(int page, int limit) {
        int offset = (page-1)*limit;
        List<Article> articles = articleDao.selectArticle(offset, limit);
        int count = articleDao.selectArticleCount();
        map.put("code",0);
        map.put("msg","");
        map.put("data",articles);
        map.put("count",count);
        return map;
    }

    //app最新文章
    @Override
    @Transactional
    public List<Article> selectNewArticle(int count) {
        return articleDao.selectNewArticle(count);
    }
}
